<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:rich="http://richfaces.org/rich">

	<h:head>
		<title>Overview</title>
		<h:outputStylesheet library="css" name="style.css" />
	</h:head>

	<h:body>
	<f:view locale="#{languageBean.currentLocale}">
			<h:form>
				<h:panelGrid columns="2">
					<h:commandLink action="#{languageBean.changeLocale('de_DE')}">
						<h:graphicImage library="img" name="german.jpg" />
					</h:commandLink>
					<h:commandLink action="#{languageBean.changeLocale('en')}">
						<h:graphicImage library="img" name="english.jpg" />
					</h:commandLink>
				</h:panelGrid>
			</h:form>
		</f:view>
		<br />
		<h:outputText value="#{msg.guestbook_overview}" styleClass="h1" />
		<br />
		<br />
		<h:panelGrid columns="3">
			<h:outputText value="#{msg.guestbook_overview_user}" styleClass="h2" />
			<h:outputText value="#{sessionBean.username}" styleClass="h3" />
			<h:graphicImage library="img" name="user.jpg" />
		</h:panelGrid>
		<br />
		<br />
		<h:form>
			<rich:dataTable id="guestbookEntries" value="#{guestbookBean.guestbookEntries}" var="entry">
				<f:facet name="noData">#{msg.guestbook_overview_nodata}</f:facet>
				<rich:column>
					<f:facet name="header">
                    	<h:outputText value="#{msg.guestbook_overview_name}" />
                    </f:facet>
					<h:outputText value="#{entry.name}" />
				</rich:column>
				<rich:column>
					<f:facet name="header">
                    	<h:outputText value="#{msg.guestbook_overview_email}" />
                    </f:facet>
					<h:outputText value="#{entry.email}" />
				</rich:column>
				<rich:column>
					<f:facet name="header">
                    	<h:outputText value="#{msg.guestbook_overview_postDate}" />
                    </f:facet>
					<h:outputText value="#{entry.postDate}">
						<f:convertDateTime pattern="dd.MM.yyyy HH:mm:ss" timeZone="GMT+1" />
					</h:outputText>
				</rich:column>
				<rich:column>
					<f:facet name="header">
                    	<h:outputText value="#{msg.guestbook_overview_title}" />
                    </f:facet>
					<h:outputText value="#{entry.title}" />
				</rich:column>
				<rich:column>
					<f:facet name="header">
                    	<h:outputText value="#{msg.guestbook_overview_text}" />
                    </f:facet>
					<h:outputText value="#{entry.text}" />
				</rich:column>
                <rich:column>
                    <f:facet name="header">
                        <h:outputText value="#{msg.guestbook_overview_delete}" />
                    </f:facet>
			         <h:commandButton action="#{guestbookBean.delete(entry.id)}" value="#{msg.guestbook_overview_action_deleteButton}" />
                </rich:column>
                <rich:column>
                    <f:facet name="header">
                        <h:outputText value="#{msg.guestbook_overview_edit}" />
                    </f:facet>
                     <h:commandButton action="#{editBean.edit(entry.id)}" value="#{msg.guestbook_overview_action_editButton}" />
                </rich:column>
			</rich:dataTable>
			<br />
			<h:commandButton action="#{logoutBean.logout}" value="#{msg.guestbook_overview_action_logout}" />
		</h:form>
        <h:link value="Create new entry" outcome="guestbookCreateEntry" />
	</h:body>

</html>
